<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE topic
  PUBLIC "-//OASIS//DTD DITA Composite//EN" "ditabase.dtd">
<topic id="topic1" xml:lang="en">
  <title id="gf143896">pg_class</title>
  <body>
    <p>The system catalog table <codeph>pg_class</codeph> catalogs tables and most everything else
      that has columns or is otherwise similar to a table (also known as <i>relations</i>). This
      includes indexes (see also <xref href="pg_index.xml#topic1">pg_index</xref>), sequences,
      views, composite types, and TOAST tables. Not all columns are meaningful for all relation
      types.</p>
    <table id="gf143898">
      <title>pg_catalog.pg_class</title>
      <tgroup cols="4">
        <colspec colnum="1" colname="col1" colwidth="131pt"/>
        <colspec colnum="2" colname="col2" colwidth="65.25pt"/>
        <colspec colnum="3" colname="col3" colwidth="93.75pt"/>
        <colspec colnum="4" colname="col4" colwidth="147pt"/>
        <thead>
          <row>
            <entry colname="col1">column</entry>
            <entry colname="col2">type</entry>
            <entry colname="col3">references</entry>
            <entry colname="col4">description</entry>
          </row>
        </thead>
        <tbody>
          <row>
            <entry colname="col1">
              <codeph>relname</codeph>
            </entry>
            <entry colname="col2">name</entry>
            <entry colname="col3"/>
            <entry colname="col4">Name of the table, index, view, etc.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relnamespace</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_namespace.oid</entry>
            <entry colname="col4">The OID of the namespace (schema) that contains this
              relation</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>reltype</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_type.oid</entry>
            <entry colname="col4">The OID of the data type that corresponds to this table's row
              type, if any (zero for indexes, which have no pg_type entry)</entry>
          </row>
          <row>
            <entry><codeph>reloftype</codeph></entry>
            <entry>oid</entry>
            <entry>pg_type.oid</entry>
            <entry>The OID of an entry in <codeph>pg_type</codeph> for an underlying composite
              type.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relowner</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_authid.oid</entry>
            <entry colname="col4">Owner of the relation</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relam</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_am.oid</entry>
            <entry colname="col4">If this is an index, the access method used (B-tree, Bitmap, hash,
              etc.)</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relfilenode</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3"/>
            <entry colname="col4">Name of the on-disk file of this relation; <codeph>0</codeph> if
              none.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>reltablespace</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_tablespace.oid</entry>
            <entry colname="col4">The tablespace in which this relation is stored. If zero, the
              database's default tablespace is implied. (Not meaningful if the relation has no
              on-disk file.)</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relpages</codeph>
            </entry>
            <entry colname="col2">int4</entry>
            <entry colname="col3"/>
            <entry colname="col4">Size of the on-disk representation of this table in pages (of 32K
              each). This is only an estimate used by the planner. It is updated by
                <codeph>VACUUM</codeph>, <codeph>ANALYZE</codeph>, and a few DDL commands.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>reltuples</codeph>
            </entry>
            <entry colname="col2">float4</entry>
            <entry colname="col3"/>
            <entry colname="col4">Number of rows in the table. This is only an estimate used by the
              planner. It is updated by <codeph>VACUUM</codeph>, <codeph>ANALYZE</codeph>, and a few
              DDL commands.</entry>
          </row>
          <row>
            <entry><codeph>relallvisible</codeph></entry>
            <entry>int32</entry>
            <entry/>
            <entry>Number of all-visible blocks (this value may not be up-to-date).</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>reltoastrelid</codeph>
            </entry>
            <entry colname="col2">oid</entry>
            <entry colname="col3">pg_class.oid</entry>
            <entry colname="col4">OID of the TOAST table associated with this table,
                <codeph>0</codeph> if none. The TOAST table stores large attributes "out of line" in
              a secondary table.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relhasindex </codeph>
            </entry>
            <entry colname="col2">boolean</entry>
            <entry colname="col3"/>
            <entry colname="col4">True if this is a table and it has (or recently had) any indexes.
              This is set by <codeph>CREATE INDEX</codeph>, but not cleared immediately by
                <codeph>DROP INDEX</codeph>. <codeph>VACUUM</codeph> will clear if it finds the
              table has no indexes.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relisshared</codeph>
            </entry>
            <entry colname="col2">boolean</entry>
            <entry colname="col3"/>
            <entry colname="col4">True if this table is shared across all databases in the system.
              Only certain system catalog tables are shared.</entry>
          </row>
          <row>
            <entry><codeph>relpersistence</codeph></entry>
            <entry>char</entry>
            <entry/>
            <entry>The type of object persistence: <codeph>p</codeph> = heap or append-optimized
              table, <codeph>u</codeph> = unlogged temporary table, <codeph>t</codeph> = temporary
              table.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relkind</codeph>
            </entry>
            <entry colname="col2">char</entry>
            <entry colname="col3"/>
            <entry colname="col4">The type of object<p><codeph>r</codeph> = heap or append-optimized
                table, <codeph>i</codeph> = index, <codeph>S</codeph> = sequence, <codeph>t</codeph>
                = TOAST value, <codeph>v</codeph> = view, <codeph>c</codeph> = composite type,
                  <codeph>f</codeph> = foreign table, <codeph>u</codeph> = uncatalogued temporary
                heap table, <codeph>o</codeph> = internal append-optimized segment files and EOFs,
                  <codeph>b</codeph> = append-only block directory, <codeph>M</codeph> = append-only
                visibility map</p></entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relstorage</codeph>
            </entry>
            <entry colname="col2">char</entry>
            <entry colname="col3"/>
            <entry colname="col4">The storage mode of a table<p><codeph>a</codeph>=
                append-optimized, <codeph>c</codeph>= column-oriented, <codeph>h</codeph> = heap,
                  <codeph>v</codeph> = virtual, <codeph>x</codeph>= external table.</p></entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relnatts</codeph>
            </entry>
            <entry colname="col2">int2</entry>
            <entry colname="col3"/>
            <entry colname="col4">Number of user columns in the relation (system columns not
              counted). There must be this many corresponding entries in pg_attribute.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relchecks</codeph>
            </entry>
            <entry colname="col2">int2</entry>
            <entry colname="col3"/>
            <entry colname="col4">Number of check constraints on the table.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relhasoids</codeph>
            </entry>
            <entry colname="col2">boolean </entry>
            <entry colname="col3"/>
            <entry colname="col4">True if an OID is generated for each row of the relation.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relhaspkey</codeph>
            </entry>
            <entry colname="col2">boolean </entry>
            <entry colname="col3"/>
            <entry colname="col4">True if the table has (or once had) a primary key.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relhasrules</codeph>
            </entry>
            <entry colname="col2">boolean</entry>
            <entry colname="col3"/>
            <entry colname="col4">True if table has rules.</entry>
          </row>
          <row>
            <entry><codeph>relhastriggers</codeph></entry>
            <entry>boolean</entry>
            <entry/>
            <entry>True if table has (or once had) triggers.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relhassubclass</codeph>
            </entry>
            <entry colname="col2">boolean</entry>
            <entry colname="col3"/>
            <entry colname="col4">True if table has (or once had) any inheritance children.</entry>
          </row>
          <row>
            <entry>
              <codeph>relispopulated</codeph>
            </entry>
            <entry>
              boolean
            </entry>
            <entry></entry>
            <entry>True if relation is populated (this is true for all relations other than some
              materialized views).</entry>
          </row>
          <row>
            <entry><codeph>relreplident</codeph></entry>
            <entry>char</entry>
             <entry></entry>
            <entry>Columns used to form “replica identity” for rows: d = default (primary key, if
              any), n = nothing, f = all columns i = index with <codeph>indisreplident</codeph> set, or
              default</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relfrozenxid</codeph>
            </entry>
            <entry colname="col2">xid</entry>
            <entry colname="col3"/>
            <entry colname="col4">All transaction IDs before this one have been replaced with a
              permanent (frozen) transaction ID in this table. This is used to track whether the
              table needs to be vacuumed in order to prevent transaction ID wraparound or to allow
              <codeph>pg_clog</codeph> to be shrunk. <p>The value is <codeph>0</codeph>
                (<codeph>InvalidTransactionId</codeph>) if the relation is not a table or if the
                table does not require vacuuming to prevent transaction ID wraparound. The table
                still might require vacuuming to reclaim disk space.</p></entry>
          </row>
          <row>
            <entry><codeph>relminmxid</codeph></entry>
            <entry>xid</entry>
            <entry></entry>
            <entry>All multixact IDs before this one have been replaced by a transaction ID in this
              table. This is used to track whether the table needs to be vacuumed in order to
              prevent multixact ID wraparound or to allow <codeph>pg_multixact</codeph> to be
              shrunk. Zero (<codeph>InvalidMultiXactId</codeph>) if the relation is not a
              table.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>relacl</codeph>
            </entry>
            <entry colname="col2"> aclitem[]</entry>
            <entry colname="col3"/>
            <entry colname="col4">Access privileges assigned by <codeph>GRANT</codeph> and
              <codeph>REVOKE</codeph>.</entry>
          </row>
          <row>
            <entry colname="col1">
              <codeph>reloptions</codeph>
            </entry>
            <entry colname="col2"> text[]</entry>
            <entry colname="col3"/>
            <entry colname="col4">Access-method-specific options, as "keyword=value"
              strings.</entry>
          </row>
        </tbody>
      </tgroup>
    </table>
  </body>
</topic>
